package com.api.mc
{
	import __AS3__.vec.*;
	
	import com.api.StaticData;
	import com.api.vo.RecommendObjVO;
	import com.game.btnClass.*;
	import com.game.utils.*;
	
	import flash.display.*;
	
	public class Recommend extends BasicMc
	{
		public var closeBtn:MovieClip;
		public var page:ChangePage;
		private var _listSP:Sprite;
		private var _closeFun:Function;
		private var _list:Vector.<RecommendObjVO>;
		private var _total:uint;
		private var _perNum:uint = 3;
		//游戏推荐
		public function Recommend()
		{
			return;
		}
		
		public function init(list:Vector.<RecommendObjVO>, closeFun:Function) : void
		{
			_list = list;
			for(var i:uint=0;i<_list.length;i++){
				if(_list[i].id==StaticData.gameId){
					_list.splice(i,1);
					break
				}
			}
			_total = _list.length;
			_closeFun = closeFun;
			addMouseEvent(new BtnClass_goto(closeBtn, closeFun));
			_listSP = new Sprite();
			addChild(_listSP);
			page.init(copyList, _total, _perNum);
		}
		
		public function gc() : void
		{
		}
		
		private function copyList(sNum:uint, eNum:uint) : void
		{
			delList();
			for(var i:uint=sNum;i<=eNum;i++){
				var _listMc:RecommendListMc = new RecommendListMc(_list[i-1]);
				_listMc.x = 40 + (i - sNum) * 108;
				_listMc.y = 58;
				_listSP.addChild(_listMc);
			}
			
		}
		
		private function delList() : void
		{
			GlobalFun.removeAllDisObj(_listSP);
		}
		
	}
}
